<?php $this->headLink()->appendStylesheet($this->dirCss.'/news.css');?>
<?php $this->headLink()->appendStylesheet($this->dirCss.'/UI_loading.css');?>
<?php
	$this->title = $this->translate("Add Page");
	$this->headTitle ( $this->title );
?>
<?php echo $this->render('common/header.phtml'); ?>
<script type="text/javascript">
<!--
	
	
	tinyMCE.init({
		mode : "textareas",
		theme : "advanced",
		theme_advanced_buttons1 : "formatselect,fontselect,fontsizeselect,mymenubutton,bold,italic,underline,separator,strikethrough,justifyleft,justifycenter,justifyright,justifyfull,bullist,numlist,link,unlink,forecolor,emotions",
		theme_advanced_buttons2 : "",
		theme_advanced_buttons3 : "",
		theme_advanced_toolbar_location : "top",
		theme_advanced_toolbar_align : "left",
		theme_advanced_statusbar_location : "bottom",
		editor_selector : "mceSimple",
		extended_valid_elements : "iframe[src|width|height|name|align]",
		//skin : "o2k7",
		file_browser_callback : "ajaxfilemanager",
	});
	
	tinyMCE.init({
		mode : "textareas",
		theme : "advanced",
		plugins : "pagebreak,style,table,save,advhr,emotions,iespell,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,wordcount,advlist,autosave",
		theme_advanced_buttons1 : "styleselect,formatselect,fontselect,fontsizeselect,|,bold,italic,underline,strikethrough,justifyleft,justifycenter,justifyright,justifyfull,|,preview,fullscreen",
		theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,code,|,forecolor,backcolor",
		theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,ltr,rtl",
		theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,pagebreak,restoredraft",
		theme_advanced_buttons5 : "",  
		relative_urls : false,
		remove_script_host : false,  
		theme_advanced_toolbar_location : "top",
		theme_advanced_toolbar_align : "left",
		file_browser_callback : "ajaxfilemanager",
		mode : "specific_textareas",
        editor_selector : "mceAdvanced",
        object_resizing : true
		//editor_selector : "mceAdvanced"
		//editor_selector : "mceSimple"
	});
	/**/

 
	function ajaxfilemanager(field_name, url, type, win) {
		/*		console.log('vao day');

		var ajaxfilemanagerurl = "../../../../../default/js/tiny_mce/plugins/ajaxfilemanager/ajaxfilemanager.php?editor=tinymce";
		switch (type) {
			case "image":
				break;
			case "media":
				break;
			case "flash": 
				break;
			case "file":
				break;
			default:
				return false;
		}
/**/
		tinyMCE.activeEditor.windowManager.open({
			url: "../../../../../default/js/tiny_mce/plugins/ajaxfilemanager/ajaxfilemanager.php?editor=tinymce",
				width: 1024,
				height: 540,
				inline : "yes",
				close_previous : "no"
			},{
			window : win,
			input : field_name
			});
	 } 
//-->
</script>
<!-- start content-outer ........................................................................................................................START -->
<div id="content-outer">

	<!-- start navigation -->
		<?php echo $this->render('common/navigation.phtml');?>
	<!-- END navigation -->
	
	<!-- start content -->
	<div id="content">

		<!--  start page-heading -->
		<div id="page-heading">
			<h1><?php if((int)$this->id){?><?php echo $this->language->l('Edit News');?><?php }else{?><?php echo $this->language->l('Add Page');?><?php }?></h1>
		</div>
		<!-- end page-heading -->


		<div id="content-border">

			<div id="content-add-inner">
			
				<?php 
					if($this->error){
					?>
						<div id="message-red">
						<?php foreach( $this->error as $val ){?>
							<div class="error-red-left">
								<?php echo $val;?>
								<a class="close-red">
									<img src="<?php echo $this->dirImg.'/table/icon_close_red.gif' ?>"   alt="" />
								</a>
							</div>
						<?php }?>
						<br /><br /><br />
						</div>
					<?php
					}elseif($this->successfully){
					?>
						<!--  start message-green -->
						<div id="message-green">
							<div class="error-green-left">
								<?php echo $this->language->l('successfully');?>
								<a class="close-green"><img src="<?php echo $this->dirImg;?>/table/icon_close_green.gif"   alt="" /></a>
							</div>
						<br /><br /><br />
						</div>
						<!--  end message-green -->
					<?php
					}
				?>
				
				<!-- start id-form -->
				<form id="add-form" method="post" action="" enctype="multipart/form-data">
				
					<label class="add-label"><?php echo $this->translate('Course list:')?></label>
					<div class="add-inp">
					
						<div id="taxonomy-list">
						
							<select name="course" class="taxonomy" size="4">
								<?php echo $this->taxonomyList; ?>
							</select>
						</div><!--  END #taxonomy-list -->
					</div>
					
					<label class="add-label"><?php echo $this->translate('Category List:')?></label>
					<div class="add-inp">
							<select name="category" id="category-list" size="4">
								<?php echo $this->categoryList; ?>
							</select>
					</div>
				
					<?php 	foreach( $this->language->getLanguages() as $vLang ){ //Lấy danh sách language ?>
						<div lang="<?php echo $vLang['code'];?>" <?php if($vLang['code'] != $this->defaultLanguage) echo 'style="display:none"';?> id="form-content-wrapper">
							
		
							<label class="add-label"><?php echo $this->translate('Title:')?></label>
							<div class="add-inp">
								<input type="text" name="name[<?php echo $vLang['code'];?>]" value="<?php echo @$this->formData['name'][$vLang['code']]?>"/>
							<?php foreach( $this->language->getLanguages() as $flagLang ){?>
									<img class="lang" 
										 name="<?php echo $flagLang['code'];?>"
										 src="<?php echo $this->dirImg."/flag/".$flagLang['code']?>.png" />
							<?php }?></div>
		
							<label class="add-label"><?php echo $this->translate('Excerpt:')?></label>
							<div class="add-inp">
								<textarea name="excerpt[<?php echo $vLang['code'];?>]" class="add-textarea"><?php echo @$this->formData['excerpt'][$vLang['code']]?></textarea>
							<?php foreach( $this->language->getLanguages() as $flagLang ){?>
							<img class="lang" name="<?php echo $flagLang['code'];?>"
									src="<?php echo $this->dirImg."/flag/".$flagLang['code']?>.png" />
							<?php }?></div>
		
		
							<label class="add-label"><?php echo $this->translate('Content:')?></label>
							<div class="add-inp">
								<textarea rows="15" name="content[<?php echo $vLang['code'];?>]" class="add-textarea mceAdvanced"><?php echo @$this->formData['content'][$vLang['code']]?></textarea>
							<?php foreach( $this->language->getLanguages() as $flagLang ){?>
							<img class="lang" name="<?php echo $flagLang['code'];?>"
									src="<?php echo $this->dirImg."/flag/".$flagLang['code']?>.png" />
							<?php }?></div>
							
							</div><!--  END #form-content-wrapper -->
						<?php }//END foreach?>
						
							<label class="add-label"><?php echo $this->translate('Representative Image:')?></label>
							<div class="add-inp">
								<input type="file" name="represent_image" value=""/>
								<div class="clear_row"></div>
					        	<?php if(@$this->formData['represent_image']) {?>
						 			<input style="margin-top: 50px" type="hidden" name="represent_image_old" value="<?php echo $this->formData['represent_image']; ?>">
						 			<img style="width: 102px; height: 102px; float:left" src="<?php echo $this->baseUrl('/public/images/system/'.$this->formData['represent_image'])?>" alt="" />
					 			<?php }else{?>
					 				<input type="hidden" name="represent_image_old" value="" size="20">
					 				<img style="width: 102px; height: 102px;"  src="<?php echo $this->baseUrl('/public/images/system/nophoto.jpg')?>" alt="" />
					 			<?php }?>
							</div>
							
							<label class="add-label"><?php echo $this->translate('author:')?></label>
							<div class="add-inp">
								<input type="text" name="author" value="<?php echo @$this->formData['author']?>"/>
							</div>
		
							<label class="add-label"></label>
							<div class="add-inp">
								<input 	type="submit" name="submit"
										value="<?php echo $this->language->l("submit");?>"
										class="form-submit" />
								<input 	type="reset" name="reset"
										value="<?php echo $this->language->l("reset");?>"
										class="form-reset" />
							</div>
						
					
					<input type="hidden" name="id" value="<?php echo @$this->id;?>" />
				</form>
				<!-- end id-form  -->
			</div>

		</div>
		<!-- END #content-border -->

	</div>
	<!--  end content -->

	<div class="clear">&nbsp;</div>
</div>
<!--  end content-outer........................................................END -->
<script type="text/javascript">
	var loadingUrl = <?php echo '"'.$this->baseUrl('/public/images/system/loading.gif').'"' ?>;
	
	$(document).ready(function(){
		$('.taxonomy').change(function(){
			var taxonomyId = $(this).val();
			$.ajax({
				type: "POST",
				data: taxonomyId,
				url: "<?php echo $this->baseUrl('/admin/page/getpagelist/id/');?>"+taxonomyId,					
				//dataType: "json",
				beforeSend: function (){
					lockScreen();
				},
				success: function(response){
					$('#category-list').html(response);
					releaseScreen();
				}
			});
		});
	});
</script>
<?php echo $this->render('common/footer.phtml'); ?>